---
title: clsRSPrint
summary: API reference for clsRSPrint.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Services.Printing
reference_type: embedded
---

# clsRSPrint

`clsRSPrint` is the protocol gateway for SQL Server Reporting Services in this library: it resolves the SSRS
`ReportExecution2005` endpoint from the Environment API, accumulates report parameters, and renders a
server-catalog report to one of several supported formats. Unlike `clsPrint`, its environment-service-injecting
constructor is `Private`, so it can only be constructed through the ambient `AppGlobal.EnvironmentService`
path, making it untestable with a substitute environment service.*

## Purpose
- Resolve the `sqlReportingServiceUrl` SSRS endpoint from the Environment API at construction time
- Load and execute a server-catalog report by path, with optional parameters, under the hosting process's
  default credentials ([BR-PRT-020](../../business-rules.md#br-prt-020-ssrs-execution-under-hosting-process-identity))
- Fix the rendered file extension to match the selected report `Format`
  ([BR-PRT-011](../../business-rules.md#br-prt-011-rendered-file-extension-fixed-by-format))

## Context
- Namespace: `SAIF.Services.Printing`
- Assembly/package: `SAIF.Services.Printing` (embedded library, project reference)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `Formats` | `Public Enum Formats {CSV, Excel, HTML, Image, PDF, Word, XML}` | Enumerates the supported SSRS render targets |
| `ImageFormats` | `Public Enum ImageFormats {BMP, EMF, GIF, JPEG, PNG, TIFF}` | Enumerates supported image sub-formats used when `Format = Image` |
| `Format` | `Public Property As Formats` | Setting it fixes both the SSRS format string and the file extension used on render ([BR-PRT-011](../../business-rules.md#br-prt-011-rendered-file-extension-fixed-by-format)) |
| `ImageFormat` | `Public Property As ImageFormats` | Setting it maps the enum to the SSRS image-format string; the mapped value is stored but not passed to `Render2`** |
| `ReportPath` | `Public Property As String` | Server-side catalog path of the report to execute |
| `New()` | `Public Sub New()` | Resolves the ambient `AppGlobal.EnvironmentService` and delegates to the private constructor |
| `AddParameter` | `Public Sub AddParameter(inName As String, inValue As String)` | Appends a report parameter to the pending collection |
| `ClearParameters` | `Public Sub ClearParameters()` | Empties the pending parameter collection so an instance can be reused for another execution |
| `PreviewDocument` | `Public Function PreviewDocument() As Byte()` | Loads the report, applies pending parameters when present, renders it, and returns the rendered bytes |
| `DistributeDocument` | `Public Sub DistributeDocument()` | Always throws `NotImplementedException` — SSRS distribution is unsupported ([BR-PRT-012](../../business-rules.md#br-prt-012-ssrs-distribution-not-supported)) |

## Behavioral notes
- `PreviewDocument` sets the proxy credentials to `System.Net.CredentialCache.DefaultCredentials`, so the report
  executes under the hosting process/user identity ([BR-PRT-020](../../business-rules.md#br-prt-020-ssrs-execution-under-hosting-process-identity)); report-level data authorization is therefore
  delegated to the SSRS server.
- `PreviewDocument` calls `LoadReport2(ReportPath, HistoryID)` with an uninitialised history ID — a source
  comment notes that initialising it causes an "invalid SnapshotId" failure.*
- `Render2`'s warnings and stream-ID outputs are received but discarded.*
- This library issues no SQL of its own — the report definition on the SSRS server owns the query.

## Constraints and usage notes
- The parameterised constructor is `Private`; only the ambient `AppGlobal.EnvironmentService` path is
  reachable, so `clsRSPrint` cannot be constructed with a substitute environment service from outside the
  library.
- Call `ClearParameters` before reusing an instance for a different report execution to avoid stale parameter
  carryover.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Services.Printing/clsRSPrint.vb
